package com.hopster;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import java.util.Random;

public class LogicalMath extends Activity 
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tester);
        Random random = new Random();
        final int dt = random.nextInt(10);
        final int i = random.nextInt(10);
        
        TextView Question = (TextView) findViewById(R.id.query);
        Question.setText(i +", " + i*dt + ", " + i*dt*dt + "...");
        
        Button dismButton = (Button) findViewById(R.id.dismiss);
        dismButton.setOnClickListener(new OnClickListener() 
        {
        	
        	public void onClick(View v) 
        	{
        		//get the values from the edittext field
        		EditText answer = (EditText)findViewById(R.id.ans);
        		int checkAnswer = -1;
        		
        		
        		//check for input
        		
        		if(answer.getText().toString().length() == 0)
        		{
        			
        		}
        		else
        		checkAnswer = java.lang.Integer.parseInt(answer.getText().toString());
        		
        		//finish
        		if(checkAnswer == (i*dt*dt*dt))
        			{
        			finish();
        			}
        		else{}
        			//answer.setText(checkAnswer);
        		
        	}
        });
        
        Button skipButton = (Button) findViewById(R.id.skip);
        skipButton.setOnClickListener(new OnClickListener() 
        {
        	public void onClick(View v) 
        	{
        		Intent intent = getIntent();
        		finish();
        		startActivity(intent);
        	}
        });
        
        Button snooButton = (Button) findViewById(R.id.snooze);
        snooButton.setOnClickListener(new OnClickListener() 
        {
        	public void onClick(View v) 
        	{
        		finish();
        	}
        });
    }
}